#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e8 + 5;
int a[MAXN];
int f[MAXN];
int main()
{
    freopen ("color.in", "r", stdin);
    freopen ("color.out", "w", stdout);
    int T;
    scanf("%d", &T);
    for(int z = 1; z <= T; z++)
    {
        int n, ans = 0;
        scanf("%d", &n);
        for(int i = 1; i <= n; i++)
        {
            scanf("%d", &a[i]);
        }
        f[0] = 1;
        for(int i = 0; i <= n; i++)
        {
            for(int j = 1; j < i; j++)
            {
                f[i] = max (f[j] - 1, f[j] + i - j);
            }
            ans = f[i];
        }
        printf("%d\n", ans);
    }
    return 0;
}
